<%--
  Created by IntelliJ IDEA.
  User: shisjin
  Date: 2023/9/25
  Time: 2:02
  To change this template use File | Settings | File Templates.
--%>
<%@ page import="java.util.*,java.text.SimpleDateFormat" contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>session2</title>
</head>
<body>
    <h2>session2内置对象</h2>
    <%
        //获取session的创建时间
        Date date = new Date(session.getCreationTime());
        SimpleDateFormat format = new SimpleDateFormat(
                "yyyy年MM月dd日 HH:mm:ss");
        //设置session属性
        session.setAttribute("user", "admin");
        session.setAttribute("password", "123456");
        //设置session生存周期为2秒
        //session.setMaxInactiveInterval(2);
    %>
    session对象的创建时间:
    <%=format.format(date)%><br> session对象的ID:<%=session.getId()%><br>

</body>
</html>
